#pragma once
#include "Chunk.h"

class TiXmlNode;
class TiXmlElement;

namespace ChunkSystem
{
	class InternalChunk
		:public Chunk
	{
	public:
		InternalChunk( const String& strChunkId, Chunk* pOwnerChunk );
		virtual~ InternalChunk(void);

		virtual bool Load( TiXmlElement* pChunkData );

	protected:

		virtual bool _LoadBoundaryInfo( TiXmlNode* pData , BoundariesData& rBoundriesData );
		virtual bool _FormPortal( Chunk* pToChunk, Portal& oportal );

	};

	class InternalChunkFactory
		:public ChunkItemFactory
	{
	public:
		InternalChunkFactory(void){}
		virtual ~InternalChunkFactory(void){}

		virtual String GetType(void);

	protected:
		virtual ChunkItem* _CreateImpl( ChunkItem* pOwner, TiXmlElement* pChunkItemData );
	};

	class ExternalChunk
		:public Chunk
	{
	public:
		
		typedef std::vector<InternalChunk*>	InternalChunks;

		ExternalChunk(const String& rId, ChunkSpace* pOwnerSpace);
		virtual ~ExternalChunk(void);

		//for automatically import terrain test
		virtual bool Load( TiXmlElement* pChunkData );

	protected:

		virtual bool _LoadBoundaryInfo( TiXmlNode* pData , BoundariesData& rBoundriesData );
		virtual bool _FormPortal( Chunk* pToChunk, Portal& oportal );

	private:

		TiXmlNode* _CreateBoundaryData( TiXmlNode* pChunkRoot, const Common::Vector3& normal , float d);
		TiXmlNode* _CreatePortalData( TiXmlNode* pBoundary, const String& portalLable, const String& strConnectChunk, const Common::Vector3& uAxis, const Common::Vector3& pt0 , 
			const Common::Vector3& pt1 , const Common::Vector3& pt2 , const Common::Vector3& pt3 );
	};

	class HeavenChunk
		:public Chunk
	{
	public:
		HeavenChunk(ChunkSpace* pOwnerSpace);
		virtual ~HeavenChunk(void){}

		virtual bool _LoadBoundaryInfo( TiXmlNode* pData , BoundariesData& rBoundriesData ){return true;}

	};

	class HellChunk
		:public Chunk
	{
	public:
		HellChunk(ChunkSpace* pOwnerSpace);
		virtual ~HellChunk(void){}

		virtual bool _LoadBoundaryInfo( TiXmlNode* pData , BoundariesData& rBoundriesData ){return true;}

	};



}